<template>
  <h1>子给父数据</h1>
  <button @click="clickMe">发送数据给父组件</button>
</template>

<script>
  //data methods 需要在created创建后才能够初始化
  //beforeCreate 
  import { ref } from 'vue'
  export default {
    emits: ['SubClick'],
    setup(props, context)
    {
      //props 里面放的是响应式的数据
      // console.log(props)

      // console.log(context.attrs.SubData)

      var son = ref('子组件的数据')

      let { attrs, slots, emit } = context


      function clickMe()
      {
        console.log('触发点击事件')
        emit('SubClick', son)
      }

      return {
        son,
        clickMe
      }
    }
  }
</script>